//车辆详情
$(".car-info").click(function(){
    $(".myshowbox").show();
});
$(".btn_close").click(function(){
    $(".myshowbox").hide();
});

// 优惠活动
$(".ck-discount-code").click(function(){
    $(".discount-box").show();
    $(".corperate-box").hide();

    // $.ajax({
    //     type: "get",
    //     url: "${pageContext.request.contextPath}/customer-coupon/customerCouponList",
    //     headers: {"token": token},
    //     success: function (result) {
    //         var customerCouponList = result.data;
    //         if (customerCouponList != null){
    //             for (var i = 0;i<customerCouponList.length;i++){
    //                 var coupon = customerCouponList[i];
    //
    //                 var ele = "<div className=\"discountcode-box\">\n"+
    //                             "<div className=\"discountcode-intro discountcode-usable\" title=\""+coupon.couponName+"\">\n"+
    //                                 "<div className=\"discountcode-info\">\n"+
    //                                     "<div className=\"discountcode-price\"><em>￥</em><span className=\"yhFree\">"+100+"</span></div>\n"+
    //                                         "<div className=\"discountcode-validity\">有效期至"+coupon.couponExpiryTime+"</div>\n" +
    //                                 "</div>\n"+
    //                                     "<div className=\"discountcode-title\">"+coupon.couponName+"</div>\n" +
    //                             "</div>\n"+
    //                            "</div>\n"
    //
    //                 $("#promotioncodediv").append(ele);
    //             }
    //
    //         }
    //
    //     }
    // })
});
$(".ck-ehi-act").click(function(){
    $(".discount-box").hide();
    $(".corperate-box").show();
});
$("#999").click(function(){
    $(".discount-box").hide();
    $(".corperate-box").hide();
});

var yhName = null;
var yhFree = 0;



//行无忧
$(".service-name-intro").click(function(){
    $(".hide").show();
});
$(".btn_close").click(function(){
    $(".hide").hide();
});
$(".butn").click(function(){
    $(".hide").hide();
});

//发票信息
$(".need-invoice").click(function(){
    var mark = document.querySelector(".need-invoice");
    if(mark.checked){
        $(".invoice-info").show();
    }else{
        $(".invoice-info").hide();
    }
})

//添加备注
$(".need-remark").click(function(){
    var mark = document.querySelector(".need-remark");
    if(mark.checked){
        $(".remark-info").show();
    }else{
        $(".remark-info").hide();
    }
})


//服务单选
function checkedThis(obj){
    var boxArray = document.getElementsByName('fwName');
    for(var i=0;i<boxArray.length;i++){
        if(boxArray[i]==obj && obj.checked){
            boxArray[i].checked = true;
        }else{
            boxArray[i].checked = false;
        }
    }
 }
 
 var addFwName = null;
 var addFwCost = 0;

 //总价
 function zongjia(){
    var carPrice = document.querySelector(".line-clear").firstElementChild.firstElementChild.innerText;
    var baseFwCost = document.querySelector("#servicePriceList").firstElementChild.firstElementChild.innerText;
    var totalPrice = parseInt(carPrice)+parseInt(baseFwCost);

    var allCheckBox = document.querySelectorAll(".fw");
    for(var i = 0;i<allCheckBox.length;i++){
        var checkBox = allCheckBox[i];
        // console.log(checkBox)
        if(checkBox.checked){
            addFwName = checkBox.getAttribute("data-ba-action");
            addFwCost = checkBox.parentElement.parentElement.lastElementChild.firstElementChild.nextElementSibling.innerText;
            console.log("addFwCost:"+addFwCost)
            $(".fwPrice").attr("value",addFwCost)
        }
    }

    totalPrice = totalPrice + parseInt(addFwCost) - parseInt(yhFree);

    document.querySelector(".sum_price").innerText = totalPrice;
    console.log("addFwName: "+ addFwName)
    console.log("totalPrice: "+totalPrice)
 }

 zongjia();

 //服务增加
 $(".fw").click(function(){
    zongjia();
 })

